<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<?php include(DDROOTPATH.'/cache/title/'.$pagetag.'_title.php');?>
<LINK rel=stylesheet type=text/css href="template/<?=MOBAN?>/css/common.css">
<LINK rel=stylesheet type=text/css href="template/<?=MOBAN?>/css/duihuan.css">
<LINK rel=stylesheet type=text/css href="css/colorbox.css" />
<script type="text/javascript" src="template/<?=MOBAN?>/js/jquery-1.3.2.min.js"></script>
<SCRIPT type="text/javascript" src="template/<?=MOBAN?>/js/function.js"></SCRIPT>
<SCRIPT type="text/javascript" src="js/jquery.colorbox.js"></SCRIPT>
<script language="javascript" type="text/javascript">
$(function(){
    $(".dh").colorbox({ innerWidth:500, innerHeight:300, inline:true, href:"#inline_example1"});
});
function checkmobile(str){// 正则判断
    var reg=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}(13)|(18)|(15)[0-9]{9}$)/;
    if(reg.test(str)){
        return true;
    }
    else{
        return false;
    }
}
function checkemail(str){
    reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;    
	if(reg.test(str)){    
		return true;
	}
	else{
	    return false;
	}
}
function checkqq(str){
    reg=/^[1-9]\d{4,12}$/;    
	if(reg.test(str)){    
		return true;
	}
	else{
	    return false;
	}
}
function checkForm(){
    var subm=1;
	$('.required').each(function(){
		if($(this).val()==''){
			$(this).focus().addClass('red_border');
		    alert($(this).attr('word'));
			subm=0;
			return false;
		}
    }).blur(function(){
	    if($(this).val()!=''){
		    $(this).removeClass('red_border');
		}
	});
	if(subm==0){
		return false;
	}
	if(subm==1){
		var fangshi=$('#fangshi').val();
	    var spid=$('#spid').val();
	    var tbusername=$('#tbusername').val();
	    var mobile=$('#mobile').val();
		if(!checkmobile(mobile)){
			alert('这不是一个电话号码');
			$('#mobile').focus();
			return false;
		}
	    var email=$('#email').val();
		if(!checkemail(email)){
			alert('这不是一个邮箱');
			$('#email').focus();
			return false;
		}
	    var qq=$('#qq').val();
		if(!checkqq(qq)){
			alert('这不是一个qq号');
			$('#qq').focus();
			return false;
		}
		var address=$('#address').val();
	    var remarks=$('#remarks').val();
	    $.post('ajax.php?fun=save_dh',{'fangshi':fangshi,'spid':spid,'tbusername':tbusername,'mobile':mobile,'email':email,'qq':qq,'address':address,'remarks':remarks,'fresh':Math.random()},function(data){
		    if(data==1){
				alert('提交成功');
				window.location='user/huan.php';
			}
			else{
			    alert(data);
			}
		});
	    return false;
	}
}
</script>
<style>
.red_border{ border:1px solid #F00}
.form_word{float:left;width:60px;height:30px;line-height:30px; font-family:宋体}
.form_input{float:left;width:205px;height:30px;line-height:30px; margin-bottom:10px}
</style>
</head>
<body>

<?php include("header.tpl.php");?>
<?php include("nav.tpl.php");?>
<div id="weizhi">当前位置：<a href="index.php">首页</a> > <a href="huan.php">兑换中心</a> > <?php echo $good['name'];?></div>
<div id="main">
  <div id="apDiv6">
    <div id="apDiv9">
    <?php if($_SESSION['duoduouser']!=NULL){?>
    <div id="apDiv11"></div>
    <div id="apDiv12">您好：<font color="#B1319E" size="2"><?=$_SESSION['duoduouser']?></font></div>
    <div id="apDiv13">你有积分：<font color="#B1319E" size="3"><?=$jifen?></font>&nbsp;点</div>
    <div id="apDiv133">你有余额：<font color="#B1319E" size="3"><?=$money?></font>&nbsp;元</div>
    <?php }else{?>
    <div id="apDiv22"></div>
    <div id="apDiv23"><a onclick="window.location='user/login.php?url='+encodeURIComponent(window.location.href)" style="cursor:pointer"><img src="template/<?=MOBAN?>/images/fqw_dl.gif" width="171" height="35" /></a></div><?php }?></div>
    <div id="apDiv17"><div id="apDiv18">商品兑换</div></div>
  </div>
  <div id="apDiv7"><div id="apDiv8">
  <div id="apDiv10">兑换的实物礼品无需缴纳任何费用，包括快递费。<br />
  礼品会在2-3周内寄送到您的手中。优惠券等虚拟商品将发送到您指定的电子邮箱中，也可以随时在<?php if($_SESSION['duoduouser']!=NULL){?><a href="user/huan.php">“用户中心”</a><?php }else{?><a href="user/login.php">“用户中心”</a><?php }?>中查看。</div></div>
  <div id="apDiv14">
  <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td height="60" colspan="2" nowrap="nowrap"><font color="#888888" size="5"><?php echo $name;?></font></td>
  </tr>
  <tr>
    <td width="30%"><div style="POSITION:relative;width:160px;height:160px;background-color:#FFFFFF;border:1px solid #CCCCCC;padding:15px;"><?php if($good['num']<1){$fs="<div id=swts>&nbsp;</div>";}else if($good['num']>0){$fs="<div id=syts></div>";}echo $fs;?><img  src="<?php echo $good['pic'];?>" width="160" height="160" alt="<?php echo $good['name'];?>" /></div></td>
  <td width="57%" valign="top">
    <div style="line-height:35px;margin-top:0px;font-size: 16px;color: #999999;">余额兑换 ：<font  color="#FF6600" size="6"><?php echo $good['money'];?></font>&nbsp;元</div>
    <div style="line-height:35px;margin-top:15px;font-size: 16px;color: #999999;">积分兑换 ：<font  color="#FF6600" size="6"><?php echo $good['jifen'];?></font>&nbsp;分</div>
    <div style="line-height:35px;margin-top:15px;font-size: 16px;color: #999999;">剩余库存 ：<?php echo $good['num'];?></font>&nbsp;件</div>

<div style="line-height:35px;height:35px;margin-top:20px;overflow:hidden;">
<?php if($_SESSION['duoduouser']!=NULL){?>
<a href="#xj" class="dh" onclick="$('#fangshi').val(1);$('.dhlimit').hide();$('#moneylimit').show();$('.needspend').hide();$('#needmoney').show();"><img src="template/<?=MOBAN?>/images/yedh.gif" width="120" height="35" /></a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#jf" class="dh" onclick="$('#fangshi').val(2);$('.dhlimit').hide();$('#jifenlimit').show();$('.needspend').hide();$('#needjifen').show();"><img src="template/<?=MOBAN?>/images/jfdh.gif" width="120" height="35" /></a>
<?php }else{?>
<a onclick="alert('登陆后才可兑换商品！');window.location='user/login.php?url='+encodeURIComponent(window.location.href)" style="cursor:pointer"><img src="template/<?=MOBAN?>/images/yedh.gif" width="120" height="35" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="template/<?=MOBAN?>/images/jfdh.gif" width="120" height="35" /></a>
<?php }?>
</div></td></tr></table></div>
<div id="apDiv19"><div id="apDiv20">商品详情</div>
<div id="apDiv21"><?php echo $good['content'];?></div></div></div>
<?php include("footer.tpl.php");?></div>

<!--现金兑换--------------------------------------------------------------------------------------------------------------------------------------->
<div style="display:none">
<div id='inline_example1' style='font:12px;color:#666666;width:500px;height:300px;'>
<form id="form1" name="form1" method="post" action="ajax.php?fun=save_dh" onsubmit="return checkForm()">
<!--方式-0 现金兑换--><input id="fangshi" name="fangshi" type="hidden" value="" />
<!--商品ID--><input id="spid" name="spid" type="hidden" value="<?=$good['id']?>" />

<!--左边-->
<div style='POSITION:relative;float:left;width:192px;height:290px;line-height:30px;'>
<div style="width:160px;height:160px;background-color:#FFFFFF;border:1px solid #CCCCCC;padding:15px;"><img  src="<?php echo $good['pic'];?>" width="160" height="160" alt="<?php echo $good['name'];?>" />
<div style="position:absolute;width:62px;height:61px;z-index:3;left: 0px;top: 0px;background-image: url(template/<?=MOBAN?>/images/xianjin_huan.gif);background-repeat: no-repeat;">&nbsp;</div></div>

<div class="needspend" id="needmoney" style="width:174px;height:28px;background-color:#FFFFFF;border:1px solid #CCCCCC;padding:8px;margin-top:10px;"><font color="#E84796" size="6"><?php echo $good['money'];?></font>&nbsp;余额</div>
<div class="needspend" id="needjifen" style="width:174px;height:28px;background-color:#FFFFFF;border:1px solid #CCCCCC;padding:8px;margin-top:10px;"><font color="#E84796" size="6"><?php echo $good['jifen'];?></font>&nbsp;积分</div>
</div>
<!--右边-->
<div style='float:right;width:270px;_width:300px;height:290px;line-height:30px; overflow:hidden; padding-left:30px; _padding-left:0px;'>
<!--[if !IE]><!-->  
<div style='float:right;width:300px;height:290px;line-height:30px; overflow:hidden;padding-left:0px;'>
<!--<![endif]-->
<!--1-->
<div class="form_word">姓&nbsp;&nbsp;名 *&nbsp;&nbsp;</div>
<div class="form_input"><input name='tbusername' type='text' class='ddinput required' word='请填写收货人姓名！' value='<?=$tbusername?>' id='tbusername' maxlength='10' style='width:120px;' /></div>
<!--2-->
<div class="form_word">电&nbsp;&nbsp;话 *&nbsp;&nbsp;</div>
<div class="form_input"><input name='mobile' type='text' class='ddinput required' word='请填写您的联系电话！' id='mobile' value='<?=$mobile?>' maxlength='20' style='width:150px;' /></div>
<!--3-->
<div class="form_word">地&nbsp;&nbsp;址 *&nbsp;&nbsp;</div>
<div class="form_input"><input name='address' type='text' class='ddinput required' word='请填写您的收货地址！' id='address' value='' maxlength='20' style='width:180px;' /></div>
<!--4-->
<div class="form_word">邮&nbsp;&nbsp;箱 *&nbsp;&nbsp;</div>
<div class="form_input"><input name='email' type='text' class='ddinput required' word='请填写邮箱！' id='email' value='<?=$email?>' maxlength='20' style='width:180px;' /></div>
<!--5-->
<div class="form_word">Q&nbsp;&nbsp;Q *&nbsp;&nbsp;</div>
<div class="form_input"><input name='qq' type='text' class='ddinput required' word='请填写联系QQ！' id='qq' value='<?=$qq?>' maxlength='20' style='width:180px;' /></div>
<!--6-->
<div class="form_word">说&nbsp;&nbsp;明 *&nbsp;&nbsp;</div>
<div class="form_input"><textarea name="remarks" class="ddinput required" word='请填写附加备注！' id="remarks" style="width:180px;height:44px;line-height:22px;"></textarea></div>
<div style='float:left;width:265px;height:30px;line-height:30px;margin-top:10px;color:#666666;'>
<div class="dhlimit" id="moneylimit">
<?php if($good['num']<1){?>
商品库存不足！暂时不能兑换
<?php }elseif($good['num']>0){?>
  <?php if($dhstate==0){?>
    <?php if($money<$good['money']) echo "你目前的余额不足以兑换此商品";else echo "<input type='submit' name='Submit' value=' 余额兑换 ' class='ddbutton' />";?>
    <?php }elseif($dhstate==1){?>
    <font  color="#3300FF">您提交的申请正在处理中</font> <a href="user/huan.php">>>查看详细</a>
<?php }}?>
</div>

<div class="dhlimit" id="jifenlimit">
<?php if($good['num']<1){?>
商品库存不足！暂时不能兑换
<?php }elseif($good['num']>0){?>
  <?php if($dhstate==0){?>
    <?php if($jifen<$good['jifen']) echo "你目前的积分不足以兑换此商品";else echo "<input type='submit' name='Submit' value=' 积分兑换 ' class='ddbutton' />";?>
    <?php }elseif($dhstate==1){?>
    <font  color="#3300FF">您提交的申请正在处理中</font> <a href="user/huan.php">>>查看详细</a>
<?php }}?>
</div>

</div>
</div>
</form>
</div>
</div>


</body>
</html>